home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Installers / Smaller Installer 1.1 / Hook Proc Examples / QD32Hook / QD32Hook.c next >
Encoding:
C/C++ Source or Header  |  1993-07-03  |  4.8 KB  |  135 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2.     Smaller Installer © 1993 Bill Goodman, All Rights Reserved
  3. *******************************************************************************
  4.  
  5. Quickdraw Hook Example
  6.  
  7. This installer hook procedure checks that the target machine is running System
  8. 6.0.5 or higher. It also installs the 32-bit Quickdraw file if the target
  9. machine is not running version 1.2 or higher. The hook procedure installs the
  10. Quickdraw file by enabling installation group "P" so the installer will install
  11. the 32-bit Quickdraw file in the system folder.
  12.  
  13. To use this hook procedure, you must compile this code and create a code
  14. resource with type 'SICR' and an ID of 500.  This resource should be
  15. non-preloaded, nonpurgeable, unlocked, unprotected and non-sysheap.  Copy this
  16. resource and the ALRT/DITL resources from the "QD32Hook.Misc.rsrc" file to your
  17. installer's resource file. Add the 32-bit Quickdraw file to your source archive
  18. using the following path: "{P}:$SYSTEM:32-Bit QuickDraw"
  19.  
  20. ******************************************************************************/
  21.  
  22. #include <SetUpA4.h>
  23. #include <GestaltEqu.h>
  24. #include "SIHookProc.h"
  25.  
  26.  
  27. /******************************************************************************
  28.     Module Internal Function Prototypes
  29. ******************************************************************************/
  30. void SetTargetVolFunction(void);
  31. void BeginInstallFunction(void);
  32.  
  33.  
  34. /******************************************************************************
  35.     Constant Declarations
  36. ******************************************************************************/
  37. #define groupPMask        0x8000    /* Group "P" selection mask */
  38.  
  39. /* Alert Definitions */
  40. #define sysRequiredAlrt        500    /* "Meteor requires version 6.0.5 or newer of the system software." */
  41.  
  42.  
  43. /******************************************************************************
  44.     Module Variables Declarations
  45. ******************************************************************************/
  46. SIHookParmBlk *parms;                    /* Global pointer to parameter block */
  47. Boolean gestaltFailed = false;        /* Set if Gestalt could not return result */
  48.  
  49.  
  50. /*****************************************************************************/
  51. pascal void main(
  52.         SIHookParmBlk *parmBlk    /* Pointer to parameter block */
  53.         )
  54. /******************************************************************************
  55.     This is the main entry point for the installer hook procedure.
  56. ******************************************************************************/
  57. {
  58. RememberA0();    /* This is necessary to access any global variables */
  59. SetUpA4();
  60. parms = parmBlk;
  61.  
  62. switch (parms->function)
  63.     {
  64.     case siHookSetTargetVol:
  65.         SetTargetVolFunction();
  66.         break;
  67.  
  68.     case siHookBeginInstall:
  69.         BeginInstallFunction();
  70.         break;
  71.     }
  72. RestoreA4();
  73. }
  74.  
  75.  
  76. /*****************************************************************************/
  77. void SetTargetVolFunction(void)
  78. /******************************************************************************
  79.     Input parameters:
  80.         "targetVRefNum" - Volume reference number of target volume
  81.         "groupAPFlags", "groupQUSel", "groupVZSel" - Groups currently selected
  82.                                                                     for installation
  83.     Returns:
  84.         "groupAPFlags", "groupQUSel", "groupVZSel" - New installation groups
  85.  
  86.     This function is called at startup and whenever the target volume is
  87.     changed.
  88. ******************************************************************************/
  89. {
  90. long feature;
  91.  
  92. if (Gestalt(gestaltQuickdrawVersion, &feature) != noErr)
  93.     {    /* Gestalt could not return Quickdraw version - force abort later */
  94.     gestaltFailed = true;
  95.     return;
  96.     }
  97. if (feature < gestalt32BitQD12)
  98.     {    /* Version is lower than 1.2 - enable installation group "P" */
  99.     parms->groupAPFlags |= groupPMask;
  100.     }
  101. else
  102.     {    /* Version is 1.2 or higher - disable installation group "P" */
  103.     parms->groupAPFlags &= ~groupPMask;
  104.     }
  105. }
  106.  
  107.  
  108. /*****************************************************************************/
  109. void BeginInstallFunction(void)
  110. /******************************************************************************
  111.     Input parameters:
  112.         "targetVRefNum" - Volume reference number of target volume
  113.         "groupAPFlags", "groupQUSel", "groupVZSel" - Groups currently selected
  114.                                                                     for installation
  115.     Returns:
  116.         "result" - Hook result code
  117.  
  118.     This function is called when the install button is clicked to begin
  119.     installing files.
  120. ******************************************************************************/
  121. {
  122. long feature;
  123.  
  124. /* Abort if target machine is not running system 6.0.5 or newer */
  125. if (Gestalt(gestaltSystemVersion, &feature) != noErr)
  126.     {    /* Gestalt could not return system version - force abort */
  127.     gestaltFailed = true;
  128.     }
  129. if (gestaltFailed || (feature < 0x0605))
  130.     {    /* Newer system required - display alert then force installer to abort */
  131.     StopAlert(sysRequiredAlrt, NULL);
  132.     parms->result = siHookAbort;
  133.     }
  134. }
  135.